
<?php 
$model = new Administrator_Model_Social();
$siteinfo = $model->GetAllSocial();
$title = 'Danh sách mạng xã hội';
$button = '<button class="add button" name="btadd" value="btadd" type="submit"></button>';
switch ($this->task) {
	case 'new':
	$title = 'Thêm mạng xã hội';
	$button = '<button title="Lưu" class="save button" name="btsave" value="btsave" type="submit"></button>';
	$button .= '<button title="Quay lại" class="back button" name="btback" value="btback" type="submit"></button>';
	$button .= '<button title="Trang chủ" class="option button" name="btoption" value="btoption" type="submit"></button>';
	break;
	case 'edit':
	$title = 'Thay đổi thông tin mạng xã hội';
	$button = '<button title="Lưu" class="save button" name="btsave" value="btsave" type="submit"></button>';
	$button .= '<button title="Quay lại" class="back button" name="btback" value="btback" type="submit"></button>';
	$button .= '<button title="Trang chủ" class="option button" name="btoption" value="btoption" type="submit"></button>';
	break;
	case 'list':
	$title = 'Danh sách mạng xã hội';
	$button = '<button title="Thêm" class="add button" name="btadd" value="btadd" type="submit"></button>';
	$button .= '<button title="Sửa" class="edit button" name="btedit" value="btedit" type="submit"></button>';
	$button .= '<button title="Xóa" class="delete button" name="btdelete" value="btdelete" type="submit"></button>';
	$button .= '<button class="able button" name="btable" value="btable" type="submit"></button>';
	$button .= '<button class="check button" name="btcheck" value="btcheck" type="submit"></button>';
	$button .= '<button title="Trang chủ" class="option button" name="btoption" value="btoption" type="submit"></button>';
	break;
	default:
		;
	break;
}
?>
<form method="post" enctype="multipart/form-data">
<div class="nav">
	<div class="navbutton">
		<?php echo $button;?>
	</div>
</div>
<div class="sheet">
	<div class="mana-title"><?php echo $title?></div>
	<div class="intro">
		<div class="form">
<?php 
	if($this->task != 'list'){
		$name = '';
		$image = '';
		$link ='';
		$user = '';
		$page = '';
		if($this->task == 'edit'){
			$info = $model->GetSocialInfo($this->id);
			$name = $info['name'];
			$image = '<img style="float:right;width:120px;width:110px;border:1px solid #DDD;padding:5px;box-shadow:0 0 2px #DFDFDF;" src="'.$model->ImageUrl('social', $info['image']).'">';			
			$link = $info['link'];
			$user = $info['user'] ;
			$page= $info['page'];
		}
		echo '<div class="small edit">';
			echo '<div class="element">';
				echo '<div class="eleft">Tên mạng xã hội : </div>';
				echo '<div class="eright"><input type="text" name="name" value="'.$name.'"></div>';
			echo '</div>';		
			echo '<div class="element">';
				echo '<div class="eleft">Chọn hình ảnh: </div>';
				echo '<div class="eright"><input type="file" name="image"></div>';
			echo '</div>';
			if($this->task == 'edit'){
				echo '<div class="element">';
					echo '<div class="eleft">Hình ảnh địa chỉ liên hệ :</div>';
					echo '<div class="eright">'	;	
						echo $image;
					echo '</div>';
				echo '</div>';
			}
			echo '<div class="element">';
				echo '<div class="eleft">Địa chỉ trang: </div>';
				echo '<div class="eright"><input type="text" name="link" value="'.$link.'"></div>';
			echo '</div>';
			echo '<div class="element">';
				echo '<div class="eleft">Mã số/tên đăng nhập: </div>';
				echo '<div class="eright"><input type="text" name="user" value="'.$user.'"></div>';
			echo '</div>';
			echo '<div class="element">';
				echo '<div class="eleft">Địa chỉ trang: </div>';
				echo '<div class="eright"><input type="text" name="page" value="'.$page.'"></div>';
			echo '</div>';
		echo '</div>';//end small
	}
	else {
echo '<table class="list-item">';
	echo '<thead>';
		echo '<th class="stt">STT</th>';
		echo '<th class="checkbox"><input id="selectall" type="checkbox" ></th>';
		echo '<th class="">Hình ảnh</th>';
		echo '<th class="">Tên </th>';
		echo '<th class="">Link</th>';
		echo '<th class="">User</th>';
		echo '<th class="">Action</th>';
		echo '<th class="id">ID</th>';
	echo '</thead>';
	echo '<tbody>';
	$i=1;
	foreach ($model->GetAllSocial() as $value) {
		$class="";if($i%2==0)$class = 'focus';
		echo '<tr class="'.$class.'">';
			echo '<td class="stt">'.$i.'</td>';
			echo '<td class="checkbox"><input id="'.$value['id'].'" type="checkbox" name="'.$value['id'].'" ></td>';
			echo '<td class=""><img class="thumb" style="width:50px;height:50px;" src="'.$model->ImageUrl('social', $value['image']).'"/></td>';
			echo '<td class="">'.$value['name'].'</td>';			
			echo '<td class="count">'.$value['link'].'</td>';
			echo '<td class="count">'.$value['user'].'</td>';		
			echo '<td class="action"><a href="'.BASE_URL.'/administrator/contact/social?task=edit&id='.$value['id'].'"><img src="'.$this->dirImg.'/edit.png"></a><a href="#" onclick="Deletesocial()"><img src="'.$this->dirImg.'/delete.png"></a></td>';			
			echo '<td class="id">'.$value['id'].'</td>';
			echo '</tr>';
		$i++;
	}
	echo '</tbody>';
	echo '<tfoot>';
	echo '</tfoot>';
echo '</table>';
}
?>		


		</div>
	</div>
</div>
</form>
<?php
